package com.Service;

import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;

import android.os.IBinder;

public class NetServiceY extends Service {

	private int count = 0;
	private boolean quit;
	private LocalBinder binder = new LocalBinder();

	public class LocalBinder extends Binder {
		public int getCount() {
			return count;
		}
	}

	@Override
	public IBinder onBind(Intent intent) {
		System.out.println("Service is Binding");
		return binder;
	}

	@Override
	public void onCreate() {
		System.out.println();
		new Thread() {

			@Override
			public void run() {
				while (!quit) {
					try {
						Thread.sleep(1000);
					} catch (Exception e) {

					}
					count++;
//					System.out.println(count++);
				}
				super.run();
			}

		}.start();
		super.onCreate();
	}

	@Override
	public boolean onUnbind(Intent intent) {
		System.out.println("Service is UnBinder");

		return true;
	}

	@Override
	public void onDestroy() {

		super.onDestroy();
		this.quit = false;
		System.out.println("Service is Unbinder");
	}

}
